package com.snj.bestdealer.mypage;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.snj.bestdealer.R;



public class MypageAdapter extends BaseAdapter {
	
	String tag = "ReceivedRequestAdapter";
	
	Context context;
	int layout;
	
	
	ArrayList<MypageItem> mMenuList;
	
	LayoutInflater mInflater = null;
	
	public MypageAdapter(Context _context, int _layout, ArrayList<MypageItem> _recvreqlist) {
		// TODO Auto-generated constructor stub
		
		this.context = _context;
		this.layout = _layout;
		this.mMenuList = _recvreqlist;
		
	}
	
	public void Insert(ArrayList<MypageItem> mList)
	{
		mMenuList.addAll(mList);
	}
	
	public void SetList(ArrayList<MypageItem> mList)
	{
		mMenuList = mList;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return mMenuList.size();
	}

	public MypageItem getItem(int position) {
		// TODO Auto-generated method stub
		return mMenuList.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
	
		
		MypageHolder holder = null;
		
		
		
		if(convertView == null)
		{
			mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = mInflater.inflate(layout, parent, false);
			
			
			holder = new MypageHolder();
			
			holder.img_icon = (ImageView)convertView.findViewById(R.id.img_mypageicon);
			holder.txt_title = (TextView)convertView.findViewById(R.id.txt_mypagetxt);
			
			convertView.setTag(holder);			
		}
		else
		{
			holder = (MypageHolder)convertView.getTag();
		}
		
		holder.img_icon.setImageBitmap(mMenuList.get(position).GetIcon());
		holder.txt_title.setText(mMenuList.get(position).GetTitle());
		
		return convertView;
	}
	
	
}
